package com.smarty.net.socket;

import com.smarty.net.layout.ParseTransfer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.net.Socket;
import java.util.Objects;

@Service
@Slf4j
public class WorkSocket {

    @Async
    public  void start(Socket workSocket) throws IOException {
        ParseTransfer transfer = new ParseTransfer(workSocket);
        transfer.init();
        System.out.println(transfer.getRequestLine());
        if (!Objects.isNull(transfer.getRequestLine())) {
            transfer.dispatch();
        }
        workSocket.close();
        log.info("finish 端口关闭");

    }

}
